#pragma once
#include "geometry.h"

struct IntersectionPoint
{
public:
	IntersectionPoint(DATA_TYPE _t, bool _isInside, const CVector3D& _vNormal)
		: t(_t), isInside(_isInside), vNormal(_vNormal)
	{
	}

	DATA_TYPE t;
	bool isInside;
	CVector3D vNormal;
	
};
bool IntersectionPointComp(const IntersectionPoint& lhs, const IntersectionPoint& rhs);

class CConstructiveSolidGeometry : public CGeometry
{
public:
	CConstructiveSolidGeometry(void);
	virtual ~CConstructiveSolidGeometry(void);

	virtual bool IsInGeometry(const CVector3D& vPoint) const = 0;
	virtual bool GetAllIntersectionPoints(const CRay& vRay, vector<IntersectionPoint>& vIntersectionPoints) const = 0;

	virtual void Init(boost::shared_ptr<CConstructiveSolidGeometry>& spLeft,
		boost::shared_ptr<CConstructiveSolidGeometry>& spRight,
		const CColor4& vColor, const CMaterial& material);

	virtual DATA_TYPE GetMaxValue(int iAxis) const;
	virtual DATA_TYPE GetMinValue(int iAxis) const;

protected:
	boost::shared_ptr<CConstructiveSolidGeometry> m_spLeft;
	boost::shared_ptr<CConstructiveSolidGeometry> m_spRight;
};

typedef boost::shared_ptr<CConstructiveSolidGeometry> CConstructiveSolidGeometryPtr;